/*
 * WipInventoryDAO.java
 *
 * Created on June 9, 2002, 10:01 AM
 */

package com.scalar.chiptrack.operations.reports.dao;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.scalar.ScalarException;
import com.scalar.chiptrack.db.DBTransaction;
import com.scalar.chiptrack.db.DataSource;

/**
 *
 * @author  Administrator
 * @version 
 */
public class WipInventoryDAO {

    public static void getWipInventoryReport(DBTransaction dbt) throws ScalarException{
        Connection conn = null;
        PreparedStatement ps = null;
        boolean success = false;

        try {
            
            // Get the connection from regular datasource if its not in a manual transaction
            if (dbt == null) {
                conn = DataSource.getConnection();
            }else {
                conn = dbt.getConnection();
            }
            
            ps = conn.prepareStatement("");
            
            success = true;
        }catch (Exception sqle) {
            sqle.printStackTrace();
            throw new ScalarException ("Wip/Inventory operation failed", sqle);
        }finally {
            
            // Commit/Rollback here it selef -- if its not in a manual transaction
            if (dbt == null) {
                try {
                    if (conn != null) {
                        if (success == true) {
                            conn.commit();
                        }
                        else {
                            conn.rollback();
                        }
                    }
                }catch (SQLException ignore) {}
            }

            if (ps != null) {
                try { ps.close(); } catch (SQLException ignore){}
            }
            if (conn != null) {
                try { conn.close(); } catch (SQLException ignore){}
            }
        }   
    }


}
